package felix.things.router.opc.conf.identity;

import lombok.Data;
import org.eclipse.milo.opcua.sdk.client.api.identity.AnonymousProvider;
import org.eclipse.milo.opcua.sdk.client.api.identity.IdentityProvider;
import org.eclipse.milo.opcua.sdk.client.api.identity.UsernameProvider;

@Data
public class IdentityProviderConfiguration {
    private String type = "anonymous";
    private String username;
    private String password;

    public IdentityProvider toProvider() {
        switch (this.type) {
            case "anonymous":
                return new AnonymousProvider();
            case "username":
                return new UsernameProvider(this.username, this.password);
            default:
                throw new IllegalArgumentException("unknown IdentityProviderType：" + type);
        }
    }

}
